<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2017-8-19
 * Func   列表接口
 */
defined('IN_YuLin') || exit('NO PERMIT!');

$data = ['total'=>0,'status'=>false,'rows'=>[]];

$page = max(1,intval($_GET['page']));
$size = max(1,intval($_GET['size']));
$limit = ' LIMIT '.($page * $size - $size).','.$size;

if($a == 'news')
{
	$cid = intval($_GET['id']);
	
	if($cid > 0)
	{
		$tmp = $db->getrow('SELECT COUNT(1) AS p FROM '.Table('article').' WHERE cid = '.$cid.' AND status = 1');
		$data['total'] = intval($tmp['p']);
		
		if($data['total'] > 0)
		{
			$data['rows'] = $db->getall('SELECT title,thumb,content,dateline FROM '.Table('article').' WHERE cid = '.$cid.' AND status = 1 ORDER BY id DESC '.$limit);
			foreach($data['rows'] as $key => $val)
			{
				$data['rows'][$key]['dateline'] = date('Y-m-d',$val['dateline']);
			}
		}
	}
}

$data['total'] > 0 && $data['status'] = true;

echo json_encode($data);
exit;